/*=============================================================================

  AREA APPLICATION MODULE

  FILE: area.h
  
  DESCRIPTION

    Module for Application

  EXTERNALIZED FUNCTIONS

    
  Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

                             EDIT HISTORY

  ---------  -------  -------------------------------------------------------
    when       who     what, where, why
  ---------  -------  -------------------------------------------------------
   05/26/05   pkim    Version E01.0

=============================================================================*/

#ifndef _AREA_H_
#define _AREA_H_

/*=============================================================================
  HEADER INCLUSION
=============================================================================*/
#include <mxBase.h>
/*=============================================================================
  CONSTANT DEFINITION
=============================================================================*/
//-----------------------------------------------
// IMAGE.SIZE
//-----------------------------------------------
#define AREAIMG_W					(1600)
#define AREAIMG_H					(1200)

/*=============================================================================
  MACRO DEFINITION
=============================================================================*/
//---DOUBLE.OEPRATION
#define ISNAN_(a)					__isnan__(a)
#define MAKENAN_()					__makenan__()
#define ISZERO_(a)					__iszero__(a)
#define ISSAME_(a,b)					__issame__(a,b)
/*=============================================================================
  ENUMERATORS
=============================================================================*/
//-----------------------------------------------------------------------------
// MODE
//-----------------------------------------------------------------------------
typedef enum
{
	AREA_NONE_M = 0x00,
	AREA_READ_M,
	AREA_AUTO_M,
	AREA_MANUAL_M
} AREA_MODE_e;

//-----------------------------------------------------------------------------
// RTUI
//-----------------------------------------------------------------------------
typedef enum
{
	AREA_VMAIN_RTUI = 0x00,
	AREA_VMANUAL_RTUI,
	
	AREA_MAX_RTUI
} AREA_RTUI;

//-----------------------------------------------------------------------------
// LENS
//-----------------------------------------------------------------------------
typedef enum
{
	AREA_LENS_5 = 0x00,
	AREA_LENS_10,
	AREA_LENS_20,
	AREA_LENS_50,
	AREA_LENS_100,
} AREA_LENS_e;

/*=============================================================================
  STRUCTURE DEFINITION
=============================================================================*/
//-----------------------------------------------------------------------------
// CONFIGURATION
//-----------------------------------------------------------------------------
#pragma pack(1)

//-----------------------------------------------------------------------------
// DATA DEFINITION
//-----------------------------------------------------------------------------
typedef struct
{
	// DAQ.STATUS
	dword				status;
	mcxt				watch;
	dword				mode;

	// MEATUREMENT.TIME
	int64				time_start;
	int64				time_end;
	
} area_que_s;

typedef struct
{
	// MEASURE
	double64				meaCNT;
	double64				Tstart;
	double64				Tinterval;
	
	// FILE.IO
	int64				mea_time;
	char					img_path[128];  // Image saving path
} area_cfg_s;

#pragma pack()

/*=============================================================================
  STRUCTURE DEFINITION
=============================================================================*/

/*=============================================================================
  EXTERNALIZED FUNCTION DEFINITION
=============================================================================*/
#ifdef __cplusplus
extern "C" {
#endif

//-----------------------------------------------------------------------------
// MAIN
//-----------------------------------------------------------------------------
mcxt area_alloc(ObjClient_s *c);
boolean area_free(mcxt app);

boolean area_init(mcxt app);
boolean area_close(mcxt app);

boolean area_cfg_set(mcxt app, area_cfg_s *ac);
boolean area_cfg_get(mcxt app, area_cfg_s *ac);

boolean area_mode_set(mcxt app, int32 mode);
int32 area_mode_get(mcxt app);

boolean area_rtui_set(mcxt app, int32 id, mcxt ui_cxt);

//-----------------------------------------------------------------------------
// MEASUREMENT
//-----------------------------------------------------------------------------
boolean area_mea_start(mcxt app);
boolean area_mea_new(mcxt app);
area_que_s *area_mea_head(mcxt app);
area_que_s *area_mea_tail(mcxt app);
area_que_s *area_mea_get(mcxt app);
boolean area_mea_is_doing(mcxt app);
void area_fio_remove_dir(mcxt app, int64 time);

//-----------------------------------------------------------------------------
// READ
//-----------------------------------------------------------------------------
boolean area_fgCB(mcxt app, Img2D o); // Call by image event
Img2D area_READget(mcxt app);
void area_READset(mcxt app, Img2D o); // For simulation mode only
boolean area_READclear(mcxt app); // For simulation mode only
void area_task_clear(mcxt app);

//-----------------------------------------------------------------------------
// UTIL
//-----------------------------------------------------------------------------
int32 area_exp2nsec(double64 expTIME/*0~100*/);
boolean area_report(void);

/*-------------------------------------------------------------------
  MATH.UTIL
-------------------------------------------------------------------*/
boolean __isnan__(double64 a);
double64 __makenan__(void);
boolean __iszero__(double64 a);
boolean __issame__(double64 a, double64 b);

#ifdef __cplusplus
}
#endif

#endif /* _AREA_H_ */

/*--- END OF FG.H ---*/
